import {EventKey} from "../common_for_guosheng/Key";

// import { EventKey } from '../common/Key';
cc.Class({
    extends: require('BaseGSUI'),

    properties: {
        nodMask: cc.Node,
        nodCore: cc.Node,
    },

    _onForGuoShenClose(isAction = true) {
        if (!isAction) {
            F.Ui.closeUI(this.node);
            return;
        }
        let action = cc.sequence(
            cc.scaleTo(0.1, 1.02, 1.02),
            cc.scaleTo(0.1, 0, 0),
            cc.callFunc(() => {
                F.Ui.closeUI(this.node);
            })
        )
        this.nodCore.runAction(action);
    },

    onEnter(args, isAction) {
        this.dnmdonEnter(args, isAction)
    },

    dnmdonEnter(args, isAction) {
        this.enterArgs = args;
        this.nodMask.on('touchstart', this._onForGuoShenTouchStart, this);
        if (isAction) {
            let action = cc.sequence(
                cc.scaleTo(0.1, 1.02, 1.02),
                cc.scaleTo(0.1, 1, 1)
            )
            this.nodCore.runAction(action);
        }

        F.OnEvent.fire(EventKey.EVENT_ENTER_PANEL);
    },

    onExit(args) {
        this.dnmdonExit(args);
    },

    dnmdonExit(args) {
        this.nodMask.off('touchstart', this._onForGuoShenTouchStart, this);
        F.OnEvent.fire(EventKey.EVENT_EXIT_PANEL);
    },

    _onForGuoShenTouchStart() {
        this._onForGuoShenClose();
    },
});